import pandas as pd
import numpy as np
from pandas import read_csv
from datetime import datetime
from matplotlib import pyplot 
from statsmodels.tsa.arima.model import ARIMA
from sklearn.metrics import mean_squared_error

df=pd.read_csv(r'c:\Users\26356\Desktop\python\BUY\600028SH.new.csv',header=0,index_col=0,parse_dates=True,sep=',')
y=df['Close']
print(y)
series=y
X=series.values
size=int(len(X)*0.92)
train, test = X[0:size], X[size:len(X)]
history = [x for x in train]
predictions = list()
for t in range(len(test)):
    model = ARIMA(history, order=(7,1,0))
    model_fit = model.fit()
    output = model_fit.forecast()
    yhat = output[0]
    predictions.append(yhat)
    obs = test[t]
    history.append(obs)
    history.pop(0)
    print('predicted=%f, expected=%f' % (yhat, obs))
error = mean_squared_error(test, predictions)
print('Test MSE: %.3f' % error)
# plot
pyplot.plot(test)
pyplot.plot(predictions, color='red')
pyplot.show()
#pyplot.plot(test)
